package fhp.hlhj.giantfold.module

import com.lzy.okgo.model.HttpParams
import fhp.hlhj.giantfold.interfaces.ICreateOrder
import fhp.hlhj.giantfold.javaBean.BaseBean
import fhp.hlhj.giantfold.network.UrlApis
import fhp.hlhj.giantfold.utils.LogUtil

/**
 * author: FHP
 * data: on 2018\1\23 0023 9:39
 * E-Mail: 103945089@qq.com
 */
class CreateOrderModule {
    interface OnOrderCreateListener{
        fun onCreateListener(baseBean: BaseBean)
    }

    fun createOrder(params: HttpParams,listener: OnOrderCreateListener){
        UrlApis.createOrder(params)
                .doOnSubscribe {

                }
                .subscribe({
                    data->
                    listener.onCreateListener(data)
                },{
                    error->
                    LogUtil.log("创建订单错误${error.toString()}")
                })
    }

    /**
     * 修改订单
     */
    fun changeOrder(params: HttpParams,listener: OnOrderCreateListener){
        UrlApis.changeOrder(params)
                .doOnSubscribe {

                }
                .subscribe({
                    data->
                    listener.onCreateListener(data)
                },{
                    error->
                    LogUtil.log("创建订单错误${error.toString()}")
                })
    }
}